java_binary(
    name = "NoThrowDoclet",
    srcs = ["NoThrowDoclet.java"],
    create_executable = False,
    tags = ["manual"],
)

# To regenerate the list of methods, ensure that your local JDK is as recent as possible and contains `lib/src.zip`.
# This will be the case if you are using the release binaries of the OpenJDK or if the `openjdk-<version>-source`
# package is installed.
# Then, execute
#   agent/src/main/java/com/code_intelligence/jazzer/generated/update_java_no_throw_methods_list.sh
# from the Bazel root and copy the file into
# org.jacoco.core/src/org/jacoco/core/internal/flow/java_no_throw_methods_list.dat
# in the CodeIntelligenceTesting/jacoco repository.
genrule(
    name = "java_no_throw_methods_list",
    srcs = [
        "@local_jdk//:lib/src.zip",
    ],
    outs = [
        "java_no_throw_methods_list.dat.generated",
    ],
    cmd = """
        TMP=$$(mktemp -d) && \
        unzip $(execpath @local_jdk//:lib/src.zip) -d $$TMP && \
        $(execpath @local_jdk//:bin/javadoc) \
            -doclet com.code_intelligence.jazzer.generated.NoThrowDoclet \
            -docletpath $(execpath :NoThrowDoclet_deploy.jar) \
            --module java.base \
            --source-path $$TMP/java.base \
            --out $@ && \
        sort -o $@ $@ && \
        rm -rf $$TMP""",
    tags = ["manual"],
    tools = [
        ":NoThrowDoclet_deploy.jar",
        "@local_jdk//:bin/javadoc",
    ],
)
